package com.itheima.work1118;

public class Student {
    private String name;
    private int age;
    private String sex;

    public Student(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }
    public Student(){}

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age<15||age>50){
            throw new AgeException("年龄不合理");
        }
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        if(!"男".equals(sex) && !"女".equals(sex)){
            throw new SexException("性别是男或女");
        }
        this.sex = sex;

    }
}
